package convert;

import org.apache.commons.beanutils.Converter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhangyu
 * @date 2021/11/19    0:44
 * 自定义日期转换器
 */
public class MyConvert implements Converter {


    @Override
    public Object convert(Class type, Object source) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date date = sdf.parse((String) source);
            return  date;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
